﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace Sasc.PV.Common
{
    public static class RandomHelper
    {
        public static string GenerateCode(int strLength = 8)
        {
            var str = "ABCDEFGHJKLMNOPQRSTUVWXYZ0123456789";
            var data = new byte[strLength];
            var chArray = new char[strLength];
            var length = str.Length;
            new RNGCryptoServiceProvider().GetBytes(data);
            for (int i = 0; i < strLength; i++)
            {
                chArray[i] = str[data[i] % length];
            }
            return new string(chArray);
        }
    }
}
